home *** CD-ROM | disk | FTP | other *** search
/ 130 MIDI Tool Box / 130 MIDI Tool Box.iso / mpubas / mpubas. next >
Text File  |  1987-05-09  |  2KB  |  48 lines

  1. 1  '  BASIC routine to read and write to MPU-401
  2. 2  '  Writen by:  Michel Poirier
  3. 3  '  For      :  MIDICOM, Montreal
  4. 4  '              FidoNet ID 167/111
  5. 5  '              514-744-7354
  6. 10 '---------------------------------------------------
  7. 11 '  INITIALISATION
  8. 12 '---------------------------------------------------
  9. 20 KEY OFF: DEFINT A-Z: SCREEN 0,0,0: CLS
  10. 30 '
  11. 40 COMPORT=817   ' To send commands to MPU-401
  12. 41 DATAPORT=816  ' Send & Receive DATA through this port
  13. 42 STATPORT=817  ' Read Status of MPU-401 through this port
  14. 43 DSR=128       ' Data Send Ready     READY WHEN DSR BIT IS SET
  15. 44 DRR=64        ' Data Receive Ready  READY WHEN DRR BIT IS SET
  16. 50 UART=63       ' Command to put MPU-401 in UART mode
  17. 51 ACK=254       ' Acknoledge from MPU-401
  18. 52 RST=255       ' Resets MPU-401
  19. 53 CHANNEL=0     ' MIDI channel 1
  20. 55 '
  21. 80 GOTO 260
  22. 90 '--------------------------------------------------
  23. 91 '  SEND DATA IN  MIDIOUT$  TO MPU-401
  24. 94 '--------------------------------------------------
  25. 100 WHILE (INP(STATPORT) AND DRR)=DRR: WEND
  26. 110 FOR C=1 TO LEN(MIDIOUT$)
  27. 120 OUT DATAPORT,ASC(MID$(MIDIOUT$,C,1))
  28. 130 NEXT C
  29. 140 RETURN
  30. 150 '--------------------------------------------------
  31. 151 '  READ ONE BYTE FROM MPU-401
  32. 152 '--------------------------------------------------
  33. 160 B=0
  34. 170 WHILE (INP(STATPORT) AND DSR)=DSR: WEND
  35. 180 B=INP(DATAPORT)
  36. 190 RETURN
  37. 200 '--------------------------------------------------
  38. 201 '  SEND COMMAND IN  CMD  TO MPU-401
  39. 202 '--------------------------------------------------
  40. 210 WHILE (INP(STATPORT) AND DRR)=DRR: WEND
  41. 220 OUT COMPORT,CMD
  42. 230 B=INP(DATAPORT): IF B<>ACK THEN 210
  43. 240 RETURN
  44. 250 '--------------------------------------------------
  45. 251 '  PROGRAM START
  46. 252 '--------------------------------------------------
  47. 260 CMD=UART: GOSUB 210
  48.